﻿<%@ Page Language="C#" MasterPageFile="~/MasterPages/MasterPage1.master" AutoEventWireup="true" CodeFile="NguoiDung_TimKiemSanPham.aspx.cs" Inherits="ChucNang_NguoiDung_NguoiDung_TimKiemSanPham" Title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <center>
    <h1>Tìm kiếm nâng cao</h1>
    <table>
  <tr><td>
      <asp:GridView ID="GridView1" runat="server">
      </asp:GridView>
  </td></tr>
     <tr>
    <td>Tên sản phẩm:</td><td><asp:TextBox ID="txtTenSP" runat="server"></asp:TextBox></td>
    </tr>
      <% 
       if (tvPhanLoai.SelectedValue !="")
       {
           string strconnection = ConfigurationManager.ConnectionStrings["SMOConnectionString"].ConnectionString;
           System.Data.SqlClient.SqlConnection connection = new System.Data.SqlClient.SqlConnection(strconnection);
           connection.Open();
           string query = "select tt.* " +
                          "from PHANLOAI_THUOCTINH pltt, THUOCTINH tt " +
                          "where pltt.Id_ThuocTinh=tt.Id and pltt.Id_PhanLoai=" + tvPhanLoai.SelectedValue;
           System.Data.SqlClient.SqlCommand command = new System.Data.SqlClient.SqlCommand();
           command.CommandText = query;
           command.Connection = connection;
           System.Data.SqlClient.SqlDataReader dr= command.ExecuteReader();
           if (dr.RecordsAffected != 0)
           {
           
               while (dr.Read())
               {
                   string id = dr["Id"].ToString();
                   string ten = dr["TenThuocTinh"].ToString();
                   Response.Write("<tr>");
                   Response.Write("<td>" + ten + "</td>");
                   Response.Write("<td><input type='text' name='" + id +"'/></td>");
                   Response.Write("</tr>");
               }
               
           }
       }
    %>
    <tr>
    <td colspan='2'>
        <asp:Button ID="btnTim" runat="server" Text="Tìm" onclick="btnTim_Click" 
            Width="61px" /></td>
    </tr>
    <tr>
         <td>
            <asp:TreeView ID="tvPhanLoai" runat="server" 
                ontreenodepopulate="tvPhanLoai_TreeNodePopulate" ExpandDepth="1">
                <SelectedNodeStyle BackColor="#FF99FF" />
            </asp:TreeView>
       </tr>
    </table>
    
    </center>
</asp:Content>

